package com.metrology.app.dao.impl;

import java.util.List;

import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.metrology.app.dao.TestDao;
import com.metrology.app.domain.Test;

public class TestDaoImpl extends SqlSessionDaoSupport implements TestDao {
	
	private static Logger logger = LoggerFactory.getLogger(TestDaoImpl.class);
	
	public void insert(Test test) throws Exception{
		try {
			getSqlSession().insert(
					"com.metrology.app.persistence.TestMapper.insert",
					test);
		} catch (Exception e) {
			if (logger.isErrorEnabled()) {
				logger.error("Write database failure.", e);
			}
			throw new Exception(e);
		}
	}

	@Override
	public List<Test> findAll() throws Exception {
		try {
			return getSqlSession().selectList(
					"com.metrology.app.persistence.TestMapper.findAll");
		} catch (Exception e) {
			if (logger.isErrorEnabled()) {
				logger.error("Query Test List failure.", e);
			}
			throw new Exception(e);
		}
	}
	
	
	
}
